//
//  UserEditNameSexCell.m
//  CheekiOS
//
//  Created by mac on 2017/6/17.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "UserEditNameSexCell.h"
@interface UserEditNameSexCell ()
@property (nonatomic, strong) UILabel *Name;
@property (nonatomic, strong) UILabel *NameLab;
@property (nonatomic, assign) NSIndexPath *indexPath;
@property (nonatomic, strong) UILabel *linLab;

@end
@implementation UserEditNameSexCell

+ (instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath {
    static NSString *UserEditNameSexCellIdent = @"UserEditNameSexCellIdent";
    UserEditNameSexCell *cell = [tableView dequeueReusableCellWithIdentifier:UserEditNameSexCellIdent];
    if (!cell) {
        cell = [[UserEditNameSexCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UserEditNameSexCellIdent];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    

    if (indexPath.row == 2) {
        cell.accessoryType = NO;

    }else{
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    }
    
    cell.indexPath = indexPath;
    return cell;
    
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.Name = [UILabel new];
        self.Name.font = FontBold(15);
        self.Name.textColor = [UIColor blackColor];
        self.Name.textAlignment = NSTextAlignmentLeft;
        [self addSubview: self.Name];
        
        self.NameLab = [UILabel new];
        self.NameLab.font = FontP(15);
        self.NameLab.textColor = RGB(175, 177, 180);
        self.NameLab.textAlignment = NSTextAlignmentRight;
        [self addSubview:self.NameLab];
    
        self.linLab = [UILabel new];
        self.linLab.backgroundColor = TheLinColor;
        [self addSubview:self.linLab];
    
    }
    return self;
}


-(void)setInfoModel:(UserpersionlInfoModel *)infoModel{

    if (_indexPath.row == 0) {
        
        self.Name.text = @"姓名";
        self.NameLab.text = infoModel.nickName;
        
    }else if(_indexPath.row == 1){
        
        self.Name.text = @"年龄";
        self.NameLab.text = infoModel.age;
        
    }else if (_indexPath.row == 2){
        
        self.Name.text = @"性别";
        if (infoModel.sex == 1) {
            self.NameLab.text = @"男";
        }else{
            self.NameLab.text = @"女";
        }
        
    }else if (_indexPath.row == 3){
        self.Name.text = @"身高";
        
        if (infoModel.height.length>0) {
            
            self.NameLab.text = [NSString stringWithFormat:@"%@cm",infoModel.height];
        }else{
            self.NameLab.text = @"请选择";
        }

    }else if (_indexPath.row == 4){
        self.Name.text = @"体重";
        if (infoModel.weight.length>0) {
            self.NameLab.text = [NSString stringWithFormat:@"%@kg",infoModel.weight];
        }else{
            self.NameLab.text = @"请选择";
        }
    }else if(_indexPath.row == 5){
        self.Name.text = @"职业";
        if (infoModel.job.length>0) {
            self.NameLab.text = @"已填写";
        }else{
            self.NameLab.text = @"未填写";
        }
        
    }else if (_indexPath.row == 6){
        self.Name.text = @"情感";
        if (infoModel.affection.length>0) {
            self.NameLab.text = @"已填写";
        }else{
            self.NameLab.text = @"未填写";
        }
        
    }else if(_indexPath.row == 7){
        self.Name.text = @"个性签名";
        if (infoModel.motto.length>0) {
            self.NameLab.text = @"已填写";
        }else{
            self.NameLab.text = @"未填写";
        }
    }else if (_indexPath.row == 8){
        self.Name.text = @"个性标签";
        if (infoModel.skill.length>0) {
            self.NameLab.text = @"已填写";
        }else{
            self.NameLab.text = @"未填写";
        }
    }else{
        self.Name.text = @"贴脸儿账号";
        self.NameLab.text =[NSString stringWithFormat:@"%ld", (long)infoModel.uid];

    }

    
    CGFloat NameLabFloat;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
        NSLog(@"ipad");
        NameLabFloat =40;
        
    }else{
        NameLabFloat = 20;
        
        NSLog(@"iphone or ipod");
    }
    
    
    [self.Name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self).offset(0);
        make.width.mas_equalTo(100);
        make.bottom.equalTo(self).offset(-1);
    }];
    
    [self.NameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        if (_indexPath.row == 2) {
            make.right.equalTo(self).offset(-NameLabFloat);
        }else{
            make.right.equalTo(self).offset(-NameLabFloat*2);
            
        }
        make.top.equalTo(self).offset(0);
        make.bottom.equalTo(self).offset(-1);
        make.width.mas_equalTo(200);
    }];
    
     [self.linLab mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.equalTo(self).offset(15);
         make.height.mas_equalTo(1);
         make.width.mas_equalTo(KScreenWidth);
         make.top.equalTo(self.NameLab.mas_bottom).offset(0);

     }];
    

}


@end
